<template>

    <div>
        <div>
            <Table border ref="selection" :columns="columns4" :data="data1" @on-selection-change="changeSelection"></Table>

        </div>

        <div style="border-top: 1px solid red;">
            <div v-for="item in data1">
                item.key --> {{ item.key}}      item.value --> {{ item.value}}    item._checked --> {{item._checked}}
            </div>
        </div>

        <!--<input type="text" v-model="xxx">-->

        <!--{{xxx}}-->
    </div>

</template>

<script>

    export default {
        name: 'index',
        data () {
            return {
                xxx: 'xxx',
                columns4: [
                    {
                        type: 'selection',
                        width: 60,
                        align: 'center'
                    },
                    {
                        title: 'Key',
                        key: 'key',
                        // render: function (h) {
                        //     return (
                        //         <div>fdasfdas</div>
                        //     )
                        // }
                        render: (h, params) => {
                            return h('Input', {
                                props: {
                                    value: params.row.key
                                },
                                on: {
                                    'on-change': (val) => {
                                        // params.row.value = val;
                                        // _this.itemsCopy[params.row._index].value = val;
                                        console.log('val -->', val);
                                    },
                                    // 'on-focus': (e) => {
                                    //     this.upToDown = true;
                                    //     this.downToUp = false;
                                    // }
                                }
                            });
                        }
                    },
                    {
                        title: 'Value',
                        key: 'value',
                        render: (h, params) => {
                            return h('Input', {
                                props: {
                                    value: params.row.value
                                },
                                // on: {
                                //     input: (val) => {
                                //         // params.row.value = val;
                                //         _this.itemsCopy[params.row._index].value = val;
                                //     },
                                //     'on-focus': (e) => {
                                //         this.upToDown = true;
                                //         this.downToUp = false;
                                //     }
                                // }
                            });
                        }
                    }
                ],
                data1: [
                    {
                        key: '',
                        value: '',
                        _checked: true
                    }
                ]
            };
        },

        methods: {
            changeSelection: function () {
                console.log('dsfsdafdsa');
            }
        },

        watch: {
            data1: {
                handler(newName, oldName) {
                    console.log('obj.a changed');
                },
                // immediate: true,
                deep: true

            }
        }
    };
</script>

<style scoped>

</style>
